package com.guodu.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.guodu.base.BaseDao;
import com.guodu.dao.ViewPurchasingTwoDetailDao;
import com.guodu.entity.ViewPurchasingTwoDetail;
import com.guodu.vo.ViewVo;

@Repository("viewPurchasingTwoDetailDao")
public class ViewPurchasingTwoDetailDaoImpl extends BaseDao implements ViewPurchasingTwoDetailDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<ViewPurchasingTwoDetail> findByVo(ViewVo viewVo) {
		// TODO Auto-generated method stub
		StringBuffer hql = new StringBuffer("from ViewPurchasingTwoDetail where 1=1");
		if(viewVo!=null){
			if(viewVo.getFunitsId()!=null){
				hql.append(" and funitsId = "+viewVo.getFunitsId());
			}
			if(viewVo.getUnitsId()!=null){
				hql.append(" and unitsId = "+viewVo.getUnitsId());
			}
			if(viewVo.getTime()!=null&&viewVo.getTime().trim().length()>0){
				hql.append(" and years = '"+viewVo.getTime().split("-")[0]+"' and month = '"+viewVo.getTime().split("-")[1]+"'");
			}
		}
		return super.find(hql.toString());
	}

}
